package cn.itcast.controller;

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    @Autowired
    protected HttpServletRequest request;
    @Autowired
    protected HttpServletResponse response;
    @Autowired
    protected HttpSession session;


    protected User getUser() {
        return (User) session.getAttribute("loginUser");
    }
//    获取当前登录人的企业id
    public String getCompanyId(){
        User user = getUser();
        if(user==null){
            return null;
        }
        return user.getCompanyId();
    }


    //    获取当前登录人的企业名称
    public String getCompanyName(){
        User user = getUser();
        if(user==null){
            return null;
        }
        return user.getCompanyName();
    }
}
